package com.zjl;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.jar.Attributes.Name;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LifeServlet
 */
public class LiSiServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public LiSiServlet() {//构造方法
        // TODO Auto-generated constructor stub
    	System.out.println("servlet被实例化");
    }
    @Override
    public void init() throws ServletException {
    	// TODO Auto-generated method stub
    	//super.init();
    }
    
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
   
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
    	String age=request.getParameter("age");
		String sex=request.getParameter("sex");
		
    	response.setCharacterEncoding("UTF-8");//设置输出内容的编码格式
		response.setContentType("text/html");//设置输出的文件类型
		PrintWriter out = response.getWriter();//响应页面
		out.println("请求携带的年龄:"+age+"<br/>");
		out.println("请求携带的性别:"+sex);
		out.flush();
		out.close();// 关闭输出流
		//查询
		//jdbc 技术
	}
    @Override 
    public void destroy() {    
    	System.out.println("销毁方法 "); 
    }
    
}
